#include <iostream>
#include "string.h"

using namespace std;


//        for(; i < m && str[i+j] == substr[i]; i++) { }
int foo(const char *str, const char *substr) {
    int n = strlen (str);
    int m = strlen (substr);

    for(int j = 0; j < n - m; j++) {
        int i = -1;
        while ( ++i < m && str[i+j] == substr[i]) { }

        if(i == m) { return j; }
    }
    return -1;
}



int main() {

    const char* mas = "abacabdacababadabacacabaca";
    const char* daba = "daba";

    cout << foo(mas, daba) << endl;

    cout << "Hello world!" << endl;
    return 0;

}
